package com.sss.hloster0508;

public class ShareData {
	static int data = 0;

	public static void main(String[] args) {
		ShareThread01 st01 = new ShareThread01();
		ShareThread02 st02 = new ShareThread02();
		new Thread(st01).start();
		new Thread(st02).start();
	}
//内部类，访问类中静态成员变量 data
	private static class ShareThread01 implements Runnable {
		public void run() {
			while (data < 100) {
				try {
					Thread.sleep(1000);
					System.out.println("这个小于10 的数据是：" + (data++));
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

	// 内部类，访问类中静态成员变量data
	private static class ShareThread02 implements Runnable {
		public void run() {
			while (data < 10000) {
				data++;
			}
		}
	}
}
